<template>
    <el-button @click="router.push('/Login')">用户退出</el-button>
    <el-container>
        <el-aside width="200px">
            <el-tree :default-expand-all="true" style="max-width: 600px" :data="meuns" :props="defaultProps"
                @node-click="handleNodeClick" />
        </el-aside>
        <el-main>


            <RouterView />
        </el-main>
    </el-container>
</template>

<script setup lang="ts">
import { ref, inject, onMounted } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus';
import { useRouter, useRoute } from 'vue-router'
import { type AxiosStatic } from 'axios'


const axios = inject('axios') as AxiosStatic
const router = useRouter()
const route = useRoute()
onMounted(() => {
    GetRoleMeunByid()
})
//菜单显示根据不同用户显示
const meuns = ref([])

const GetRoleMeunByid = () => {
    axios.get('/RbacMan/GetRoleMeunByid', {
        params: {
            roleId:
                //route.query.roleId,
                localStorage.getItem("roleId"),
            pid: 0
        }
    }).then(res => {
        meuns.value = res.data
    })
}


const handleNodeClick = (data: any) => {

    console.log(data)
    router.push({
        name: data.labelUrl
    })
}
const defaultProps = {
    children: 'children',
    label: 'label',
    labelUrl: "labelUrl",
}



</script>